﻿using PhotoAlbums.Models;
using System.Linq;
using System.Web.Mvc;
using System.Data.Entity;

namespace PhotoAlbums.Controllers
{
    public class HomeController : Controller
    {
        private PhotoAlbumsDB db = new PhotoAlbumsDB();

        public ActionResult Index()
        {
            // 未登录跳转
            if (Session["id"] == null)
            {
                return RedirectToAction("Login", "User");
            }
            return View(db.Photo.ToList());
        }

        public ActionResult About()
        {
            // 未登录跳转
            if (Session["id"] == null)
            {
                return RedirectToAction("Login", "User");
            }

            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            // 未登录跳转
            if (Session["id"] == null)
            {
                return RedirectToAction("Login", "User");
            }

            ViewBag.Message = "Your contact page.";

            return View();
        }

        public ActionResult Error(string msg)
        {
            // 未登录跳转
            if (Session["id"] == null)
            {
                return RedirectToAction("Login", "User");
            }

            ViewBag.Message = msg;

            return View();
        }
    }
}